{{/* url: the URL format, "%s" is the username placeholder */}}
{{/* icon: the Font Awesome icon class */}}
{{- $socials := dict
  "artstation" (dict "url" "https://www.artstation.com/%s" "icon" "fab fa-artstation" "color" "#0a5878")
  "bilibili" (dict "url" "https://space.bilibili.com/%s" "icon" "fab fa-bilibili" "color" "#fb7299")
  "bitbucket" (dict "url" "https://bitbucket.org/%s" "color" "#0e65df")
  "discord" (dict "url" "https://discord.com/invite/%s" "icon" "fab fa-discord")
  "discourse" (dict "url" "%s" "icon" "fab fa-discourse")
  "dockerhub" (dict "url" "https://hub.docker.com/u/%s" "icon" "fab fa-docker")
  "facebook" (dict "url" "https://facebook.com/%s" "icon" "fab fa-facebook-f" "color" "#1877f2")
  "facebookgroup" (dict "url" "https://facebook.com/groups/%s" "icon" "fab fa-facebook-square" "color" "#1877f2")
  "github" (dict "url" "https://github.com/%s")
  "gitlab" (dict "url" "https://gitlab.com/%s" "color" "#e24329")
  "instagram" (dict "url" "https://www.instagram.com/%s" "color" "#c03957")
  "itchio" (dict "url" "https://%s.itch.io/" "icon" "fab fa-itch-io")
  "kaggle" (dict "url" "https://kaggle.com/%s" "color" "#3cc6ff")
  "lastfm" (dict "url" "https://www.last.fm/user/%s" "color" "#ba0000")
  "liberapay" (dict "url" "https://liberapay.com/%s" "icon" "fab fa-liberapay")
  "linkedin" (dict "url" "https://linkedin.com/in/%s" "icon" "fab fa-linkedin-in" "color" "#0a66c2")
  "mastodon" (dict "url" "https://mastodon.social/@%s" "icon" "fab fa-mastodon" "color" "#5c4ce2")
  "medium" (dict "url" "https://medium.com/@%s" "icon" "fab fa-medium-m")
  "patreon" (dict "url" "https://www.patreon.com/%s" "icon" "fab fa-patreon" "color" "#ff424d")
  "paypal" (dict "url" "https://www.paypal.com/paypalme/%s" "icon" "fab fa-paypal")
  "pinterest" (dict "url" "https://www.pinterest.com/%s" "icon" "fab fa-pinterest" "color" "#cc0000")
  "qq" (dict "url" "https://wpa.qq.com/msgrd?v=3&uin=%s&site=qq&menu=yes")
  "quora" (dict "url" "https://www.quora.com/profile/%s" "color" "#b92b27")
  "reddit" (dict "url" "https://www.reddit.com/user/%s" "color" "#FF4500")
  "stackoverflow" (dict "url" "https://stackoverflow.com/users/%s" "icon" "fab fa-stack-overflow" "color" "#f48024")
  "telegram" (dict "url" "https://t.me/%s" "icon" "fab fa-telegram-plane" "color" "#2481cc")
  "tipeee" (dict "url" "https://fr.tipeee.com/%s" "icon" "fab fa-tipeee" "color" "#f2485b")
  "tiktok" (dict "url" "https://www.tiktok.com/@%s" "icon" "fab fa-tiktok")
  "tumblr" (dict "url" "https://%s.tumblr.com")
  "twitter" (dict "url" "https://twitter.com/%s" "color" "#1d9bf0")
  "website" (dict "url" "%s" "icon" "fas fa-link")
  "weibo" (dict "url" "https://weibo.com/%s" "color" "#e1162c")
  "xing" (dict "url" "https://www.xing.com/profile/%s" "icon" "fab fa-xing")
  "youtube" (dict "url" "https://www.youtube.com/channel/%s" "icon" "fab fa-youtube" "color" "#ff0000")
  "zhihu" (dict "url" "https://www.zhihu.com/people/%s" "color" "#056de8")
-}}
{{- $size := default "" .size }}
{{- $linkClass := default "" .linkClass }}
{{- $color := default true .color }}
{{- $iconText := default false .iconText }}
{{- $iconTextClass := default "ms-1" .iconTextClass }}

<nav class="social-links nav justify-content-center{{ with .class }} {{ . }}{{ end }}">
{{- range $key, $user := .links }}
  {{- if eq $key "email" }}
    <a class="nav-link social-link{{ with $linkClass }} {{ . }}{{ end }}" href="mailto:{{ $user }}" title="{{ "social_email" | i18n }}">
      <i class="fas fa-fw{{ with $size }} {{ . }}{{ end }} fa-envelope"{{ if and $color }} style="color: #0963ac;"{{ end }}></i>
      {{- if $iconText }}
      <span{{ with $iconTextClass }} class="{{ . }}"{{ end }}>Email</span>
      {{- end }}
    </a>
  {{- else }}
    {{- with index $socials $key }}
      {{- $link := printf .url $user }}
      {{- $url := urls.Parse $user }}
      {{- if $url.Scheme }}{{ $link = $url.String }}{{ end }}
      <a class="nav-link social-link{{ with $linkClass }} {{ . }}{{ end }}" target="_blank" href="{{ $link }}" title="{{ printf "social_%s" $key | i18n }}" rel="me">
        <i class="fa-fw{{ with $size }} {{ . }}{{ end }} {{ default ( printf "fab fa-%s" $key ) .icon }}"
          {{ if and $color .color }} style="color: {{ .color }};"{{ end }}></i>
        {{- if $iconText }}
        <span{{ with $iconTextClass }} class="{{ . }}"{{ end }}>{{ default (title $key) .title }}</span>
        {{- end }}
      </a>
    {{- end }}
  {{- end }}
{{- end }}
{{- $rss := true }}
{{- if isset .links "rss" }}
{{- $rss = ne "" .links.rss }}
{{- end }}
{{- if and (default true .params.rss) $rss }}
  {{- $rss := false }}
  {{- with .home.OutputFormats.Get "rss" }}
    {{- $rss = . }}
  {{- end }}
  {{- if ne .params.rss "home" }}
    {{- with .OutputFormats.Get "rss" }}
      {{- $rss = . }}
    {{- end }}
  {{- end }}
  {{- with $rss }}
  <a class="nav-link social-link{{ with $linkClass }} {{ . }}{{ end }}" target="_blank" href="{{ .RelPermalink }}" title="{{ "social_rss" | i18n }}" rel="me">
    <i class="fas fa-fw{{ with $size }} {{ . }}{{ end }} fa-rss"{{ if and $color }} style="color: #ea6221;"{{ end }}></i>
    {{- if $iconText }}
    <span{{ with $iconTextClass }} class="{{ . }}"{{ end }}>RSS</span>
    {{- end }}
  </a>
  {{- end }}
{{- end }}
</nav>
